import * as React from 'react'; import { DetailedHTMLProps, InputHTMLAttributes } from 'react'; import { CheckboxField, Flex, TextField } from '@aws-amplify/ui-react'; type FieldValue = DetailedHTMLProps< InputHTMLAttributes, HTMLInputElement >['value']; type FieldSetter = (event: any) => void; type FieldName = string; type ControlType = 'checkbox' | 'text' | string; export type FieldControl = [FieldValue, FieldSetter, FieldName, ControlType]; export interface GetFieldControlsProps { typeName: string; fields: FieldControl[]; } export const GetFieldControls = ({ fields }: GetFieldControlsProps) => { return ( {fields.map(([value, setter, name, type = 'text'], idx) => type === 'checkbox' ? ( { setter(event.target.checked); }} /> ) : ( { setter(event.target.value); }} /> ) )} ); };